<template>
    <div class="container">
        <div class="handle-box">
                <el-form ref="form" :model="form" label-width="90px" class="flex">
                    <!-- <el-form-item label="所属街道：">
                        <el-input v-model="name" placeholder="请输入名称" class="handle-input mr10"></el-input>
                    </el-form-item> -->
                    <el-form-item label="社区名称：">
                        <el-input v-model="name" placeholder="请输入名称" class="handle-input mr10"></el-input>
                    </el-form-item>
                    <el-form-item label="日期范围：">
                       <el-date-picker
                            v-model="value1"
                            type="daterange"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search">搜索</el-button>
                    </el-form-item>
                    
                </el-form>
            </div>
            <el-table
                :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
            >
                <el-table-column prop="id" label="ID" width="55" align="center"></el-table-column>
                <!-- <el-table-column prop="address" label="所属街道"></el-table-column> -->
                <el-table-column prop="community" label="社区名称"></el-table-column>
                <el-table-column prop="date" label="日期范围"></el-table-column>
                <!-- <el-table-column prop="integral" label="可回收垃圾累计积分"></el-table-column> -->
                <el-table-column prop="score" label="可回收垃圾消费积分"></el-table-column>
                <!-- <el-table-column prop="remaining" label="可回收垃圾剩余积分"></el-table-column>
                <el-table-column prop="chuyuintegral" label="厨余收垃圾累计积分"></el-table-column> -->
                <el-table-column prop="chuyuscore" label="厨余收垃圾消费积分"></el-table-column>
                <!-- <el-table-column prop="chuyuremaining" label="厨余收垃圾剩余积分"></el-table-column>
                <el-table-column prop="youhaiintegral" label="有害收垃圾累计积分"></el-table-column> -->
                <el-table-column prop="youhaiscore" label="有害收垃圾消费积分"></el-table-column>
                <!-- <el-table-column prop="youhairemaining" label="有害收垃圾剩余积分"></el-table-column>
                <el-table-column prop="qitaintegral" label="其他收垃圾累计积分"></el-table-column> -->
                <el-table-column prop="qitascore" label="其他收垃圾消费积分"></el-table-column>
                <!-- <el-table-column prop="qitaremaining" label="其他收垃圾剩余积分"></el-table-column> -->
                <el-table-column prop="totalintegral" label="总累计积分"></el-table-column>
                <el-table-column prop="totalscore" label="总消费积分"></el-table-column>
                <el-table-column prop="totalremaining" label="总消费积分"></el-table-column>
                <!-- <el-table-column label="垃圾分类">
                    <template slot-scope="scope">￥{{scope.row.money}}</template>
                </el-table-column>
                <el-table-column prop="address" label="积分类型"></el-table-column>
                <el-table-column label="状态" align="center">
                    <template slot-scope="scope">
                        <el-tag
                            :type="scope.row.state==='成功'?'success':(scope.row.state==='失败'?'danger':'')"
                        >{{scope.row.state}}</el-tag>
                    </template>
                </el-table-column>

                <el-table-column prop="date" label="分数规则(分)"></el-table-column> -->
                <el-table-column label="操作" width="180" align="center">
                    <template slot-scope="scope">
                        <el-button
                            type="text"
                            icon="el-icon-edit"
                            @click="handleEdit(scope.$index, scope.row)"
                        >详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="total, sizes, prev, pager, next, jumper"
                    :current-page="currentPage"  
                    :page-size="pageSize"
                    :total="tableData.length"
                    @size-change="handleSizeChange"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div>
            <!-- 详情弹出框 -->
            <el-dialog v-dialogDrag title="信息" :visible.sync="editVisible" width="50%" >
                <el-form ref="form" :model="form" label-width="70px" class="diaglos">
                    <el-form-item label="所属街道：" :label-width="formLabelWidth">
                        <el-input v-model="form.address"></el-input>
                    </el-form-item>
                    <el-form-item label="社区名称：" :label-width="formLabelWidth">
                        <el-input v-model="form.community"></el-input>
                    </el-form-item>
                    <el-form-item label="日期范围：" :label-width="formLabelWidth">
                        <el-input v-model="form.date"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="可回收垃圾累计积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.integral"></el-input>
                    </el-form-item> -->
                    <el-form-item label="可回收垃圾消费积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.score"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="可回收垃圾剩余积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.remaining"></el-input>
                    </el-form-item> -->
                    <!-- <el-form-item label="厨余垃圾累计积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.chuyuintegral"></el-input>
                    </el-form-item> -->
                    <el-form-item label="厨余垃圾消费积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.chuyuscore"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="厨余垃圾剩余积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.chuyuremaining"></el-input>
                    </el-form-item>
                    <el-form-item label="有害垃圾累计积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.youhaiintegral"></el-input>
                    </el-form-item> -->
                    <el-form-item label="有害垃圾消费积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.youhaiscore"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="有害垃圾剩余积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.youhairemaining"></el-input>
                    </el-form-item>
                    <el-form-item label="其他垃圾累计积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.qitaintegral"></el-input>
                    </el-form-item> -->
                    <el-form-item label="其他垃圾消费积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.qitascore"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="其他垃圾剩余积分：" :label-width="formLabelWidth">
                        <el-input v-model="form.qitaremaining"></el-input>
                    </el-form-item> -->
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="editVisible = false">取 消</el-button>
                    <el-button type="primary" @click="saveEdit">确 定</el-button>
                </span>
            </el-dialog>
        </div>
</template>
<script>
import '../../../assets/css/common.css'

export default {
    data(){
        return{
              currentPage:1, //初始页
                pagesize:10,    //    每页的数据
                userList: [],
                address:'',
                name:'',
                value1: '',
                formLabelWidth:'160px',
            tableData: [{
                id: '1',
                address: "街道1",
                community: '社区1',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '2',
                address: "街道2",
                community: '社区2',
                date: '2020-7-1~2020-7-20',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '3',
                address: "街道3",
                community: '社区3',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '4',
                address: "街道4",
                community: '社区4',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '5',
                address: "街道5",
                community: '社区5',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '6',
                address: "街道6",
                community: '社区6',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '7',
                address: "街道7",
                community: '社区7',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '8',
                address: "街道8",
                community: '社区8',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '9',
                address: "街道9",
                community: '社区9',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '10',
                address: "街道10",
                community: '社区10',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '11',
                address: "街道11",
                community: '社区11',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            },{
                id: '12',
                address: "街道12",
                community: '社区12',
                date: '2020-7-1~2020-7-30',
                integral: '100',
                score: '2',
                remaining:'98',
                chuyuintegral: '200',
                chuyuscore: '1',
                chuyuremaining: '199',
                youhaiintegral: '100',
                youhaiscore:　'2',
                youhairemaining:　'98',
                qitaintegral: '100',
                qitascore: '5',
                qitaremaining: '95',
                totalintegral: '500',
                totalscore: '358',
                totalremaining: '142'
            }],
            multipleSelection: [],
            delList: [],
            editVisible: false,
            pageTotal: 0,
            form: {},
            idx: -1,
            id: -1
        }
    },
    created() {
        // this.getData();
    },
    methods: {
        // 获取 easy-mock 的模拟数据
        // getData() {
        //     fetchData(this.query).then(res => {
        //         console.log(res);
        //         this.tableData = res.list;
        //         this.pageTotal = res.pageTotal || 50;
        //     });
        // },
        // 触发搜索按钮
        // handleSearch() {
        //     this.$set(this.query, 'pageIndex', 1);
        //     // this.getData();
        // },
         mohu() {
            var search = this.name;
            console.log(search)
            var newdate = [];
            if(search){
                if(search)
                 this.tableData.filter(item=>{
                    if(item.name.indexOf(search) != -1){
                        newdate.push(item)
                    }
                })
            }else if (search == ''){
                console.log(this.tableData)
            }
            this.tableData = newdate
        },
        // 编辑操作
        handleEdit(index, row) {
            this.idx = index;
            this.form = row;
            this.editVisible = true;
        },
        // 保存编辑
        saveEdit() {
            this.editVisible = false;
            this.$message.success(`修改第 ${this.idx + 1} 行成功`);
            this.$set(this.tableData, this.idx, this.form);
        },
        // 分页导航
        handlePageChange(currentPage) {
            this.currentPage = currentPage;
            console.log(this.currentPage)
            // this.$set(this.query, 'pageIndex', val);
            // this.getData();
        },
        handleSizeChange(size){
            this.pagesize = size;
            console.log(this.pagesize)
        }
    }
}
</script>
<style scoped>

</style>